<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>流程处理</title>
<jsp:include page="../../import.jsp" flush="true" />
<script src="<%=path %>/resource/lib/ueditor/ueditor.config.js" charset="utf-8" type="text/javascript"></script>
<script src="<%=path %>/resource/lib/ueditor/ueditor.all.min.js" charset="utf-8" type="text/javascript"></script>
<!--建议手动加载语言，避免在IE下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script src="<%=path %>/resource/lib/ueditor/lang/zh-cn/zh-cn.js" charset="utf-8" type="text/javascript"></script>
<!-- <script src="<%=path %>/resource/lib/plugins/iviewer/sq_iviewer.js" type="text/javascript"></script> -->
</head>
<body class="iframeBody">
    <div class="Wrapper">
        <div>
        	<div align="left">
        		<span>&nbsp;&nbsp;&nbsp;&nbsp;流程编号:</span><span style="color: red;">&nbsp;&nbsp;${procNo }</span>
        	</div>
        	<div align="left" class="btnsBox">
                <input name="processInstanceIdNm" id="processInstanceId" type="text" style="display: none;" value="${processInstanceId}"/>
                <input name="taskIdNm" id="taskId" type="text" style="display: none;" value="${taskId}"/>
                <input name="assignableIdNm" id="assignableId" type="text" style="display: none;" value="${assignable}"/>
                <input name="formUrlIdNm" id="formUrlId" type="text" style="display: none;" value="${formUrl}"/>
                <input name="processDefinitionIdNm" id="processDefinitionId" type="text" style="display: none;" value="${processDefinitionId}"/>
                <input name="processDefinitionKeyIdNm" id="processDefinitionKeyId" type="text" style="display: none;" value="${processDefinitionKey}"/>
                <input name="taskDefKeyIdNm" id="taskDefKeyId" type="text" style="display: none;" value="${taskDefKey}"/>
                <input name="flowPicUrlIdNm" id="flowPicUrlId" type="text" style="display: none;" value="${flowPicUrl}"/>
                <input name="businessKeyIdNm" id="businessKeyId" type="text" style="display: none;" value="${businessKey}"/>
                <input name="taskTypeIdNm" id="taskTypeId" type="text" style="display: none;" value="${taskType}"/>
                <input name="taskStatusIdNm" id="taskStatusId" type="text" style="display: none;" value="${taskStatus}"/>
                <input name="assigneeIdNm" id="assigneeId" type="text" style="display: none;" value="${assignee}"/>
                <input name="businessType" id="businessType" type="text" style="display: none;" value=""/>
                <input name="originTaskIdNm" id="originTaskId" type="text" style="display: none;" value="${originTaskId}"/>
                <input name="beanNameNm" id="beanNameId" type="text" style="display: none;" value="${beanName}"/>
                <input name="taskDefKeyNm" id="taskDefKeyNmId" type="text" style="display: none;" value="${taskDefKeyNm}"/>
                <input name="grpShr" id="grpShrId" type="text" style="display: none;" value="${grpShr}"/>
                <input name="onlySaveBtn" id="onlySaveBtnId" type="text" style="display: none;" value="${onlySave}"/>
                <input name="procNm" id="procNmId" type="text" style="display: none;" value="${procNm}"/>
                <input name="isSignNm" id="isSignId" type="text" style="display: none;" value="${isSign}"/>
                <span name="flowListIdNm" class="Hide" id="flowListId" style="display: block;" >${flowList}</span>
                <!-- 节点配置 -->
                <input name="isFormAuthNm" id="isFormAuthId" type="text" style="display: none;" value="${isFormAuth}"/>
                <input name="preTaskIdNm" id="preTaskIdId" type="text" style="display: none;" value="${preTaskId}"/>
                <span id="sp_private_task_id" class="sq-button sq-button-round">签收</span>
                <span id="sp_sign_task_id" class="sq-button sq-button-round">加签处理</span>
                <!-- 保存按钮  这个按钮的保存是流程状态为被加签处理人操作的,保存完本地数据调用工作流完成方法-->
                <span id="sp_save_id" class="sq-button sq-button-round Hide">保存</span>
                <!-- 保存按钮  这个按钮的保存是流程状态为被加签处理人操作的,仅保存本地数据-->
                <span id="sp_only_save_id" class="sq-button sq-button-round Hide">保存</span>
                <!-- 动态生成按钮集合 -->
                <span id="sp_dynamic_btn_id">
	                
                </span>
                <span id="sp_distribute_task_id" class="sq-button sq-button-round" style="display: none;">分配</span>
                <span id="sp_hold_task_id" class="sq-button sq-button-round">暂不处理</span>
            </div>
            <div id="pageInTab" class="pageInTab">
                <div tabid="tabA" title="任务处理" lselected="true">
                    <form id="formSet1">
                        <div class="fieldset1 tabel_col clearFix noBorder">
                            <div class="caption">
                                <span class="title">签字信息</span>
                            </div>
                            <div id="div_flow_task_info_h_id"></div>
                           <%--  <c:forEach items="${flowTaskInfoVOList }" var="fti">
                            	 <div class="fieldBox col_100">
	                               <span>${fti.taskTm } [${fti.opUsrNm }]${fti.opRlNm } : ${fti.taskName }</span>
	                            </div>
                            </c:forEach> --%>
                            <!-- <div class="fieldBox col_100">
	                               <span>2016-05-17 16:30:46 [admin]超级管理员 : 发起流程[开始] start</span>
	                        </div> -->
	                        <!-- 附件 -->
					        
                            <div class="fieldBox col_100">
                                <!-- <textarea name="taskOpinionNm" id="taskOpinionId" rows="4" class="l-textarea" style="width:99%" validate="{maxlength:200}"></textarea> -->
                                <script id="editor" type="text/plain" style="width:99%; height:300px;"></script>
                            </div>
                        </div>
                    </form>
                    
                    <div id="upload_div">
                    <jsp:include page="../../system/sysUlFilesRec/sysUlFileRecList.jsp" flush="true" >
			            <jsp:param name="pkId" value="${taskId }"/>
			            <jsp:param name="tabNm" value="SYS_FLOW_TASK_H"/>
			        </jsp:include>
                    <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true" >
						<jsp:param name="filePath" value="flow/"/>
					</jsp:include>
					</div>
                </div>
                <div tabid="tabB" title="附加信息">
                    <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
                </div>
                <div tabid="tabC" title="流程跟踪" >
                    <iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
                </div>
            </div>
        </div>
    </div>

    <script>
    var pageInApp={}; // to 下一级子窗口 接口
    var pageInTab=null;
    var loadedTabs=[]
    $(function() {
    	initTab();
    	initFlowData();
    	initFlowEvent();
    	initFlowTaskInfoH();
    	//放到最后一个
    	initBtn();
    	initUedit();
    });
    
    function initUedit(){
    	var ue = UE.getEditor('editor',{
    		toolbars:[[
                       'source', '|','undo', 'redo', '|',
                       'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', '|', 
                       'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', '|',
                       'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                       'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                       'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
                       'horizontal', 'date', 'time'
                   ]]
    	});
    	
    	/* ue.addListener("ready", function () {
            // editor准备好之后才可以使用
            ue.setContent("9999999999999999");
        }); */
    }
    
    //初始化按钮的显示与隐藏
    function initBtn(){
    	var taskTypeId = $("#taskTypeId").val();
    	var taskStatusId = $("#taskStatusId").val();
    	var onlySaveBtnId = $("#onlySaveBtnId").val();
    	//alert(onlySaveBtnId);
    	if(taskTypeId == "sign"){//被加签人只能处理有保存操作
    		//加签
    		$("#sp_sign_task_id").remove();
    		//签收
    		$("#sp_private_task_id").remove();
    		//分配
    		$("#sp_distribute_task_id").remove();
    		//暂不处理
    		$("#sp_hold_task_id").remove();
    		//动态按钮
    		$("#sp_dynamic_btn_id").remove();
    		//显示保存按钮
    		$("#sp_save_id").removeClass("Hide");
    	}
    	
    	if(taskTypeId == "assign"){//被分配人不能在分配、不能在加签
    		//分配
    		$("#sp_distribute_task_id").remove();
    		//加签
    		$("#sp_sign_task_id").remove();
    	}
    	
    	if(taskTypeId == "original" && taskStatusId == "signProcessing"){//原始任务是加签办理中的只能查看,不能办理
    		//加签
    		$("#sp_sign_task_id").remove();
    		//签收
    		$("#sp_private_task_id").remove();
    		//分配
    		$("#sp_distribute_task_id").remove();
    		//暂不处理
    		$("#sp_hold_task_id").remove();
    		//动态按钮
    		$("#sp_dynamic_btn_id").remove();
    		//显示保存按钮
    		$("#sp_save_id").remove();
    	}
    	if(onlySaveBtnId == "true"){//组内任务非本身是受理人的只能保存意见及附件,本操作不会和工作流有交互
    		//加签
    		$("#sp_sign_task_id").remove();
    		//签收
    		$("#sp_private_task_id").remove();
    		//分配
    		$("#sp_distribute_task_id").remove();
    		//暂不处理
    		$("#sp_hold_task_id").remove();
    		//动态按钮
    		$("#sp_dynamic_btn_id").remove();
    		//显示保存按钮
    		$("#sp_save_id").remove();
    		//保存按钮-只保存,和工作流引擎无交互
    		$("#sp_only_save_id").removeClass("Hide");
    	}
    	
    	//如果指定受理人不为空则不显示签收
    	/* var assignee = $("#assigneeId").val();
    	if($.trim(assignee) != ""){
    		//签收
    		$("#sp_private_task_id").remove();
    	} */
    	
    	//不显示签收,这个操作在列表页面处理了
		$("#sp_private_task_id").remove();
    	
    }
    
    //初始化流程历史节点信息
    function initFlowTaskInfoH(){
    	var _taskId = $("#taskId").val();
    	var _processDefinitionId = $("#processDefinitionId").val();
    	var _processInstanceId = $("#processInstanceId").val();
    	var _originTaskId = $("#originTaskId").val();
    	var parms = {
    			taskId:_taskId,
    			processDefinitionId:_processDefinitionId,
    			processInstanceId:_processInstanceId,
    			originTaskId:_originTaskId
    	}
    	var _url = '<%=path%>/flow/flow/initFlowTaskInfoList.do';
		AjaxUtils.ajaxGet(_url, parms, function(msg){
			if(msg.success == 1 && msg.data){
				 var html = "<div class=\"sectionBox\"><div class=\"recordTask\">";//sectionBox start
   			  $.each(msg.data, function (n, value) {
   				  html+='<div class=\"recordBox\" >'//recordBox start
   				  	  //这里做个处理,要是结束节点则不显示操作人
   				  	  var content = value.taskTm + ' [' + value.opUsrNm + ']' + value.opRlNm;
   				  	  if(FlowConstant.FLOW_TASK_ACTIVITY_TYPE_END == value.activityType){
   				  		content = "";//清空
   				  	  }
   				  	  var taskNm = "";
   				  	  if(StringUtils.isNotEmpty(value.taskName)){
   				  		taskNm = value.taskName + "->"; 
   				  	  }
   	                  html+='<div class=\"rcTit\">' + content + ' : '+ taskNm + value.outgoingFlow + '</div>';
   	                  html+="<div class=\"rcBody\">";//rcBody start
   	                  if(StringUtils.isNotEmpty(value.taskOpinion) && value.taskOpinion != "null"){
   	                  	html+='<div>' + value.taskOpinion + '</div>';
   	               	  }else{
   	               		html+='<div>&nbsp;</div>';
   	               	  }
   	                  //判断是否有附件,如果有则加入附件
   	                  html+="<div>";//div 1 start
   	                  if(value.attchmntList){
   	                	  $.each(value.attchmntList, function (nt, valuet) {
   	                		  	//判断是否是图片,如果是图片则加入target属性
   	                		  	if(StringUtils.isNotEmpty(valuet.filePath)){
   	                		  		html+="&nbsp;&nbsp;&nbsp;&nbsp;";
   	                		  		try
		   	                		{
		   	                		  	var extStart=valuet.filePath.lastIndexOf(".");
	   	                		    	var ext=valuet.filePath.substr(extStart,valuet.filePath.length).toUpperCase();
	   	                		    	if(SQ.regs.img.test(ext)){
	   	                		    		html+='<a class="fileLink" role="winOpen" href="javascript:openImgWin(';
			   	                		 	html+="'"+valuet.filePath+"'";
			   	                			html+=",'"+valuet.fileNm+"'";
			   	                			html+=')">'+valuet.fileNm+'</a>';
	   	                		    	}else{
	   	                		    		html+="<a target='_blank' class='fileLink' href='"+valuet.filePath+"'>"+valuet.fileNm+"</a>";
	   	                		    	}
		   	                		}
		   	                		catch(err)
		   	                		{
		   	                			html+="<a class='fileLink' target='_blank' href='"+valuet.filePath+"'>"+valuet.fileNm+"</a>";
		   	                		}
   	                		  	}
	    	              });
   	                  }
   	                  html+="</div>";//div 1 end
   	                  html+="</div>";//rcBody end
   	                  html+='</div>';//recordBox end
   			  });
   			  html+='</div></div>';//sectionBox end
   			  $("#div_flow_task_info_h_id").empty();
   			  $("#div_flow_task_info_h_id").html(html);
			 }else{
				 UIUtils.alertError(msg.info);
			 }
			SetIframe_height();
   	    },true);
    	
    }
    
    //初始化数据
    function initFlowData(){
    	//是否显示"分配"按钮
    	var assignable = $("#assignableId").val();
    	var isFormAuth = $("#isFormAuthId").val();//节点配置
    	if(assignable == "true"){
    		$("#sp_distribute_task_id").show();
    	}
    	//alert(flowList);
    	//动态生成按钮
    	var flowList = $("#flowListId").html();
    	//alert(flowList);
    	if(flowList){
    		var flowListObj = JSON.parse(flowList);
    		var dynamicBtnHtml = "";
    		$.each(flowListObj, function (n, value) {
    			dynamicBtnHtml += "<span taskIsFormAuth= \""+isFormAuth+"\" isFormAuth=\""+value.isFormAuth+"\" branchKey=\""+value.flowKey+"\" name=\"sp_task_dynamic_btn_name\" id=\"sp_task_dynamic_btn_id\" class=\"sq-button sq-button-round\">"+value.flowName+"</span>";
            });
    		if(dynamicBtnHtml != ""){
    			$("#sp_dynamic_btn_id").empty();
        		$("#sp_dynamic_btn_id").html(dynamicBtnHtml);
    		}
    	}
    }
    //初始化事件
    function initFlowEvent(){
    	//签收
        $("#sp_private_task_id").click(function(event) {
        	$.ligerDialog.SQconfirm("确定签收吗?", function (flag) {
        		if(flag == false)return;
	        	var _taskId = $("#taskId").val();
	        	var _processDefinitionKey = $("#processDefinitionKeyId").val();
	        	var _taskDefKey = $("#taskDefKeyId").val();
	        	var _processDefinitionId = $("#processDefinitionId").val();
	         	var _businessKey = $("#businessKeyId").val();
	         	var _processInstanceId = $("#processInstanceId").val();
	         	var _attchmnt = JSON.stringify(getUploadResultParams());//附件的集合
	         	var _taskOpinion = UE.getEditor('editor').getContent();//$("#taskOpinionId").val();
	         	var _businessType = $("#businessType").val();//业务类型
	        	var _businessBean=$("#beanName").val();
	        	var parms = {
	        			taskId:_taskId,
	        			processDefinitionKey:_processDefinitionKey,
	        			taskDefKey:_taskDefKey,
	        			processDefinitionId:_processDefinitionId,
	         			taskId:_taskId,
	         			businessKey:_businessKey,
	         			processInstanceId:_processInstanceId,
	         			attchmnt:_attchmnt,
	         			taskOpinion:_taskOpinion,
	         			businessType:_businessType,
                        businessBean:_businessBean
	        	}
	        	
	        	var _url = '<%=path%>/flow/flow/modifyFlowPrivate.do';
	    		AjaxUtils.ajaxPost(_url, parms, function(msg){
	    			if(msg.success == 1){
	   				 	UIUtils.alertSuccess(msg.info);
		   			}else{
		   				UIUtils.alertError(msg.info);
		   			}
	       	    },true);
        	});
        });
    	
        //加签处理 ,弹出选择人员窗口,选完人后进行加签操作
        $("#sp_sign_task_id").click(function(event) {
        	var This_dialog=$.ligerDialog.SQopen({
                url: "<%=path%>/flow/flow/toChooseUsrWinPage.do?isMore=1",
                width: 1000,
                title: "选择组织用户",
                onClosed: function () {
                    //alert("从子窗口传参过来:"+"\n"+JSON.stringify(This_dialog._DATA));  // _DATA是子窗口里传参给此dialog对象的
                    //alert(This_dialog._DATA.usrIds);
                    if(!This_dialog._DATA.usrIds || This_dialog._DATA.usrIds.lenght == 0){
                    	//没有选择任何人说明是关闭了窗口
                    }else{
                    	//调用加签方法
                        signTask(This_dialog._DATA.usrIds);
                    }
                }
            });
        });
        
      	//动态生成按钮操作(通过 不通过等)
        $("span[name=sp_task_dynamic_btn_name]").click(function(event) {
        	var _this = $(this);
        	var _taskId = $("#taskId").val();
        	var _branchKey = _this.attr("branchKey");
        	var _processDefinitionKey = $("#processDefinitionKeyId").val();
        	var _taskDefKey = $("#taskDefKeyId").val();
         	var _processDefinitionId = $("#processDefinitionId").val();
         	var _businessKey = $("#businessKeyId").val();
         	var _processInstanceId = $("#processInstanceId").val();
         	var _attchmnt = JSON.stringify(getUploadResultParams());//附件的集合
         	var _taskOpinion = UE.getEditor('editor').getContent();//$("#taskOpinionId").val();
        	var _businessType = $("#businessType").val();//业务类型
        	var _beanName = $("#beanNameId").val();//业务Bean名称
        	var _taskDefKeyNm = $("#taskDefKeyNmId").val();//流程定义名称
        	var _procNm = $("#procNmId").val();//流程名称
        	var btnName = _this.html();//按钮名字
        	
        	
        	var params = {
        			taskId:_taskId,
        			branchKey:_branchKey,
        			processDefinitionKey:_processDefinitionKey,
        			taskDefKey:_taskDefKey,
        			processDefinitionId:_processDefinitionId,
         			taskId:_taskId,
         			businessKey:_businessKey,
         			processInstanceId:_processInstanceId,
         			attchmnt:_attchmnt,
         			taskOpinion:_taskOpinion,
         			businessType:_businessType,
         			businessBean:_beanName,
         			taskDefKeyNm:_taskDefKeyNm,
         			procNm:_procNm
        		};
        	
        	var _taskIsFormAuth = _this.attr("taskIsFormAuth");
        	var _isFormAuth = _this.attr("isFormAuth");
        	if(_taskIsFormAuth == 1 || _isFormAuth == 1){
        		var _preTaskIdId = $("#preTaskIdId").val();
        		if(StringUtils.isEmpty(_preTaskIdId)){
        			_preTaskIdId = "";
        		}
        		var urlParms = {
            			taskId:_taskId,
            			branchKey:_branchKey,
            			procDefKey:_processDefinitionKey,
            			taskDefKey:_taskDefKey,
            			procDefId:_processDefinitionId,
            			taskId:_taskId,
            			dataId:_businessKey,
             			procInstId:_processInstanceId,
             			preTaskId:_preTaskIdId
            		}
        		//弹出任务节点配置窗口
        		$.ligerDialog.SQopen({
                    width: 800,
                    height:400,
                    title : '表单权限控制项',
                    urlParms:urlParms,
                    url:'<%=path%>/flow/flowfrmathrec/toFlowFormAuthConfig.do',
                    // 自定义buttons的时候 不要设置 fixButtons: true
                    buttons: [{
                            text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
                            onclick: function (item, Dialog) {
                                //在子页面里绑定 frameElement.dialog.onOk = function () {}
                                if (Dialog.onOk) {
                                	Dialog.onOk(function(flag){
                                		//调用完成操作
                                		if(flag==true){
                                			pubComplateTask(params);
                                		}
                                	}, btnName);
                                }
                            }
                        }, {
                            text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', 
                            onclick: function (item, Dialog) {
                                //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                                if (Dialog.onCancel) Dialog.onCancel();
                            }
                        }
                    ]
                });
        	}else{
            	$.ligerDialog.SQconfirm("确定" + btnName + "吗?", function (flag) {
            		if(flag == false)return;
                    pubComplateTask(params);
            	});
        	}
        });

        //公共使用完成任务方法
        function pubComplateTask(params) {
            var _url = '<%=path%>/flow/flow/modifyFlowComplete.do';
            AjaxUtils.ajaxPost(_url, params, function (msg) {
                if (msg.success == 1) {
                    if (msg.data) {
                        //调用mq 获取下一节点操作人
                        if(msg.info == 1){
                            alertNextFlowAssign(msg.data);
                        }else {
                            //直接提示下一节点操作人信息
                            $.ligerDialog.SQalert({
                                SQ_showButtons: true,
                                SQ_onBtnclick: function (item, Dialog) {
                                    //关闭当前Tab
                                    Remove_navTab();
                                    frameElement.dialog.close();
                                },
                                content: LogUtils.LOG_FLOW_NEXT_TASK_OPERATOR + msg.data
                            });
                        }
                    } else {
                        UIUtils.alertSuccess(msg.info);
                        Remove_navTab();
                        frameElement.dialog.close();
                    }
                } else {
                    UIUtils.alertError(msg.info);
                }
            }, true);
        }
      	
      	//分配
        $("#sp_distribute_task_id").click(function(event) {
        	var This_dialog=$.ligerDialog.SQopen({
                url: "<%=path%>/flow/flow/toChooseUsrWinPage.do?isMore=0",
                width: 1000,
                title: "选择组织用户",
                onClosed: function () {
                    //alert("从子窗口传参过来:"+"\n"+JSON.stringify(This_dialog._DATA));  // _DATA是子窗口里传参给此dialog对象的
                    //alert(This_dialog._DATA.usrIds);
                    if(!This_dialog._DATA.usrIds || This_dialog._DATA.usrIds.lenght == 0){
                    	//没有选择任何人说明是关闭了窗口
                    }else{
                    	//调用分配任务方法
                        distributeTask(This_dialog._DATA.usrIds);
                    }
                }
            });
        });
      	
      	//暂不处理-挂起
        $("#sp_hold_task_id").click(function(event) {
        	var btnName = $(this).html();//按钮名字
        	$.ligerDialog.SQconfirm("确定"+btnName+"吗?", function (flag) {
        		if(flag == false)return;
        		var _taskId = $("#taskId").val();
            	var _processDefinitionKey = $("#processDefinitionKeyId").val();
            	var _taskDefKey = $("#taskDefKeyId").val();
            	var _processInstanceId = $("#processInstanceId").val();
            	var _processDefinitionId = $("#processDefinitionId").val();
             	var _businessKey = $("#businessKeyId").val();
             	var _attchmnt = JSON.stringify(getUploadResultParams());//附件的集合
             	var _taskOpinion = UE.getEditor('editor').getContent();//$("#taskOpinionId").val();
             	var _businessType = $("#businessType").val();//业务类型
             	
            	var parms = {
            			taskId:_taskId,
            			processDefinitionKey:_processDefinitionKey,
            			processDefinitionId:_processDefinitionId,
            			taskDefKey:_taskDefKey,
            			taskId:_taskId,
             			businessKey:_businessKey,
             			processInstanceId:_processInstanceId,
             			attchmnt:_attchmnt,
             			taskOpinion:_taskOpinion,
             			businessType:_businessType
            	}
            	
            	var _url = '<%=path%>/flow/flow/modifyFlowHold.do';
        		AjaxUtils.ajaxPost(_url, parms, function(msg){
        			if(msg.success == 1){
    	   				 UIUtils.alertSuccess(msg.info);
    	   				 //关闭当前Tab
    	   				 Remove_navTab();
    	   			 }else{
    	   				 UIUtils.alertError(msg.info);
    	   			 }
           	    },true);
        	});
        });
      	
      	//保存操作
        $("#sp_save_id").click(function(event) {
        	var _taskId = $("#taskId").val();
        	var _processDefinitionKey = $("#processDefinitionKeyId").val();
        	var _taskDefKey = $("#taskDefKeyId").val();
         	var _processDefinitionId = $("#processDefinitionId").val();
         	var _businessKey = $("#businessKeyId").val();
         	var _processInstanceId = $("#processInstanceId").val();
         	var _attchmnt = JSON.stringify(getUploadResultParams());//附件的集合
         	var _taskOpinion = UE.getEditor('editor').getContent();//$("#taskOpinionId").val();
         	var _businessType = $("#businessType").val();//业务类型
        	
        	var parms = {
        			taskId:_taskId,
        			processDefinitionKey:_processDefinitionKey,
        			taskDefKey:_taskDefKey,
        			processDefinitionId:_processDefinitionId,
         			taskId:_taskId,
         			businessKey:_businessKey,
         			processInstanceId:_processInstanceId,
         			attchmnt:_attchmnt,
         			taskOpinion:_taskOpinion,
         			businessType:_businessType
        		}
        	
        	var _url = '<%=path%>/system/sysflowtaskh/add.do';
        	AjaxUtils.ajaxPost(_url, parms, function(msg){
        		if(msg.success == 1){
    				if(msg.data){
    					UIUtils.alertSuccess(msg.info + LogUtils.LOG_FLOW_NEXT_TASK_OPERATOR + msg.data);
	   				 }else{
	   					UIUtils.alertSuccess(msg.info);
	   				 }
	   				 //关闭当前Tab
	   				 Remove_navTab();
    			 }else{
    				 UIUtils.alertError(msg.info);
    			 }
       	    },true);
    	});
      	
        
      	//保存操作
        $("#sp_only_save_id").click(function(event) {
        	var _taskId = $("#taskId").val();
        	var _processDefinitionKey = $("#processDefinitionKeyId").val();
        	var _taskDefKey = $("#taskDefKeyId").val();
         	var _processDefinitionId = $("#processDefinitionId").val();
         	var _businessKey = $("#businessKeyId").val();
         	var _processInstanceId = $("#processInstanceId").val();
         	var _attchmnt = JSON.stringify(getUploadResultParams());//附件的集合
         	var _taskOpinion = UE.getEditor('editor').getContent();//$("#taskOpinionId").val();
         	var _businessType = $("#businessType").val();//业务类型
        	
        	var parms = {
        			taskId:_taskId,
        			processDefinitionKey:_processDefinitionKey,
        			taskDefKey:_taskDefKey,
        			processDefinitionId:_processDefinitionId,
         			taskId:_taskId,
         			businessKey:_businessKey,
         			processInstanceId:_processInstanceId,
         			attchmnt:_attchmnt,
         			taskOpinion:_taskOpinion,
         			businessType:_businessType
        		}
        	
        	var _url = '<%=path%>/system/sysflowtaskh/addLocal.do';
        	AjaxUtils.ajaxPost(_url, parms, function(msg){
        		if(msg.success == 1){
        			 UIUtils.alertSuccess(msg.info);
	   				 //关闭当前Tab
	   				 Remove_navTab();
    			 }else{
    				 UIUtils.alertError(msg.info);
    			 }
       	    },true);
    	});
    }

  	//分配任务
    function distributeTask(_usrIds){
    	//alert(_usrIds);
    	var _taskId = $("#taskId").val();
    	var _processDefinitionKey = $("#processDefinitionKeyId").val();
    	var _taskDefKey = $("#taskDefKeyId").val();
    	var _processDefinitionId = $("#processDefinitionId").val();
     	var _businessKey = $("#businessKeyId").val();
     	var _processInstanceId = $("#processInstanceId").val();
     	var _attchmnt = JSON.stringify(getUploadResultParams());//附件的集合
     	var _taskOpinion = UE.getEditor('editor').getContent();//$("#taskOpinionId").val();
     	var _businessType = $("#businessType").val();//业务类型
     	
    	var parms = {
    			taskId:_taskId,
    			processDefinitionKey:_processDefinitionKey,
    			taskDefKey:_taskDefKey,
    			processDefinitionId:_processDefinitionId,
     			taskId:_taskId,
     			businessKey:_businessKey,
     			processInstanceId:_processInstanceId,
     			attchmnt:_attchmnt,
     			taskOpinion:_taskOpinion,
     			businessType:_businessType,
    			usrIds:JSON.stringify(_usrIds)
    	}
    	
    	var _url = '<%=path%>/flow/flow/modifyFlowDistribute.do';
    	AjaxUtils.ajaxPost(_url, parms, function(msg){
    		 if(msg.success == 1){
				 UIUtils.alertSuccess(msg.info);
				 //关闭当前Tab
				 Remove_navTab();
			 }else{
				 UIUtils.alertError(msg.info);
			 }
   	    },true);
    }
    
    //加签任务
    function signTask(_usrIds){
    	var _taskId = $("#taskId").val();
    	var _processDefinitionKey = $("#processDefinitionKeyId").val();
    	var _taskDefKey = $("#taskDefKeyId").val();
    	var _processDefinitionId = $("#processDefinitionId").val();
     	var _businessKey = $("#businessKeyId").val();
     	var _processInstanceId = $("#processInstanceId").val();
     	var _attchmnt = JSON.stringify(getUploadResultParams());//附件的集合
     	var _taskOpinion = UE.getEditor('editor').getContent();//$("#taskOpinionId").val();
     	var _businessType = $("#businessType").val();//业务类型
    	var parms = {
    			taskId:_taskId,
    			processDefinitionKey:_processDefinitionKey,
    			taskDefKey:_taskDefKey,
    			processDefinitionId:_processDefinitionId,
     			taskId:_taskId,
     			businessKey:_businessKey,
     			processInstanceId:_processInstanceId,
     			attchmnt:_attchmnt,
     			taskOpinion:_taskOpinion,
     			businessType:_businessType,
    			usrIds:JSON.stringify(_usrIds)
    	}
    	
    	var _url = '<%=path%>/flow/flow/modifyFlowSign.do';
    	AjaxUtils.ajaxPost(_url, parms, function(msg){
   		 if(msg.success == 1){
				 UIUtils.alertSuccess(msg.info);
				 //关闭当前Tab
				 Remove_navTab();
			 }else{
				 UIUtils.alertError(msg.info);
			 }
  	    },true);
    }
    
    
    
    //初始化Tab页
    function initTab(){
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function(tabid) {
                if (loadedTabs.indexOf(tabid)<0) {
                    loadedTabs.push(tabid);
                    var domain = "<%=path%>";
                	var _formUrl = $("#formUrlId").val();
                	if(StringUtils.isNotEmpty(_formUrl)){
                	   var _businessKey = $("#businessKeyId").val();
                	   var _processInstanceId = $("#processInstanceId").val();
                	   var _taskId = $("#taskId").val();
                	   var _taskDefKey = $("#taskDefKeyId").val();
                	   var _taskDefKeyNm = $("#taskDefKeyNmId").val();
                	   var _procNm = $("#procNmId").val();
                	   var _isSing = $("#isSignId").val();
                	   var _preTaskIdId = $("#preTaskIdId").val();
                		_formUrl = /* domain +  */_formUrl + _businessKey 
                			+"&processInstanceId="+_processInstanceId
                			+"&taskId="+_taskId
                			+"&taskDefKey="+_taskDefKey
                			+"&taskNm="+_taskDefKeyNm
                			+"&procNm="+_procNm
                			+"&isSign="+_isSing
                			+"&preTaskIds="+_preTaskIdId;
                	}
                    switch (tabid){
                        case "tabB":
                        	if(StringUtils.isNotEmpty(_formUrl)){
                            	pageInTab.setTabItemSrc(tabid, _formUrl);
                        	}
                            break;
                        case "tabC":
                        	var flowPicURL = $("#flowPicUrlId").val();
                            pageInTab.setTabItemSrc(tabid, flowPicURL);
                            break;
                    }
                };
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    }
    
    //上传回调方法
    function uploadCallbackForMore(_data){
		var _taskId = $("#taskId").val();
     	var _processInstanceId = $("#processInstanceId").val();
     	var _businessKey = $("#businessKeyId").val();
     	var _attchmnt = JSON.stringify(_data);//附件的集合
    	
    	var params = {
    			taskId:_taskId,
     			businessKey:_businessKey,
     			processInstanceId:_processInstanceId,
     			attchmnt:_attchmnt
    		}
     	
    	var _url = '<%=path%>/flow/flow/uploadFlowOperator.do';
		AjaxUtils.ajaxPost(_url, params, function(msg){
			if(msg.success == 1){
				//UIUtils.alertSuccess(msg.info);
				refreshUlFileRecListByPkId(_taskId,"SYS_FLOW_TASK_H");
   			 }else{
   				UIUtils.alertError(msg.info);
   			 }
   	    },true);
    }
    
    //打开通用图片显示窗口
	function openImgWin(_url,_name){
		if(SQ.regs.img.test(_name)){
         	window.__ImgSrc = _url;
         	window.__ImgTit = _name;
         	window.open('<%=path%>/project/prjbscinfo/imgWinOpen.do', '', 'location=yes, width=800, height=600');
		}else{
	        window.open(_url);
		}
    }

    function alertNextFlowAssign(key) {
        var url = '<%=path%>/flow/flow/getFlowNextAssigne.do?key=' + key;
        var wait_dialog = $.ligerDialog.SQalert({
            content: LogUtils.LOG_CMM_DATA_LOADING,
            SQ_type: "waitting",
            onClose: function () {
            }
        });
        setTimeout(function () {
            $.ajax({
                type: 'post',
                dataType: 'json',
                url: url,
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {//成功发起流程
                        $.ligerDialog.SQalert({
                            SQ_showButtons: true,
                            SQ_onBtnclick: function (item, Dialog) {
                                //关闭当前Tab
                                Remove_navTab();
                                frameElement.dialog.close();
                            },
                            content: msg.info
                        });
                    } else if (msg.success == 0) {//错误
                        UIUtils.alertErrorHold1(msg.info);
                    }
                }
            });
        }, 8000);
    }
    </script>
</body>
</html>